package webapp.mvc.finders;

import com.zoowii.jpa_utils.extension.ExtendFinder;
import com.zoowii.jpa_utils.util.StringUtil;
import webapp.mvc.enums.IntBooleans;
import webapp.mvc.models.ShopCategoryEntity;

import java.util.List;

public class ShopCategoryFinder extends ExtendFinder<String, ShopCategoryEntity> {
    public ShopCategoryFinder(Class<?> kCls, Class<?> mCls) {
        super(kCls, mCls);
    }
    public List<ShopCategoryEntity> list() {
        return this.where().eq("deleted", IntBooleans.FALSE).all();
    }
    public ShopCategoryEntity findByName(String name) {
        if(StringUtil.isEmpty(name)) {
            return null;
        }
        return this.where().eq("deleted", IntBooleans.FALSE).eq("name", name).first();
    }
}
